Railcraft compat#384
Conversation
Wizzerinus
left a comment
There was a problem hiding this comment.
I'm not a maintainer of this mod, just mentioning some things I noticed ;)
WaitingIdly
left a comment
There was a problem hiding this comment.
a few other things:
- instead of magic numbers as defaults, use the railcraft defaults directly - ie
IRollingMachineCrafter.DEFAULT_PROCESS_TIME. - run
/gs generateWikior enablingdev_generate_wikiingradle.properties- check the log to ensure no warnings/missing lang keys. - wizz also brought up great points, listen to those.
|
|
||
| @Property(comp = @Comp(gte = 0)) | ||
| private int time = 200; | ||
| private final List<IOutputEntry> outputs = new ArrayList<>(); |
There was a problem hiding this comment.
annotate this with @Property. i would also suggest renaming this to output
| List<IRollingMachineCrafter.IRollingRecipe> recipes = new ArrayList<>(Crafters.rollingMachine().getRecipes()); | ||
| recipes.removeIf(recipe -> recipe.getRegistryName().equals(r.getKey())); |
There was a problem hiding this comment.
create a new arraylist and then remove from that list? are you sure thats correct
| List<IRollingMachineCrafter.IRollingRecipe> recipes = new ArrayList<>(Crafters.rollingMachine().getRecipes()); | ||
| recipes.removeIf(recipe -> recipe.getRegistryName().equals(r.getKey())); | ||
| }); | ||
| restoreFromBackup().forEach(r -> ModSupport.RAILCRAFT.get().rollingMachine.add(r.getKey(), r.getValue())); |
There was a problem hiding this comment.
cant do this, because RollingMachine#add runs #addScripted
| return Crafters.rollingMachine().getRecipes().removeIf(r -> { | ||
| if (output.test(r.getRecipeOutput())) { | ||
| addBackup(Pair.of(r.getRegistryName(), r)); | ||
| return true; | ||
| } | ||
| return false; | ||
| }); |
There was a problem hiding this comment.
you can compact this significantly by using doAddBackup to this
| return Crafters.rollingMachine().getRecipes().removeIf(r -> { | |
| if (output.test(r.getRecipeOutput())) { | |
| addBackup(Pair.of(r.getRegistryName(), r)); | |
| return true; | |
| } | |
| return false; | |
| }); | |
| return Crafters.rollingMachine().getRecipes().removeIf(r -> { | |
| return output.test(r.getRecipeOutput()) && doAddBackup(Pair.of(r.getRegistryName(), r)); | |
| }); |
which becomes
| return Crafters.rollingMachine().getRecipes().removeIf(r -> { | |
| if (output.test(r.getRecipeOutput())) { | |
| addBackup(Pair.of(r.getRegistryName(), r)); | |
| return true; | |
| } | |
| return false; | |
| }); | |
| return Crafters.rollingMachine().getRecipes().removeIf(r -> output.test(r.getRecipeOutput()) && doAddBackup(Pair.of(r.getRegistryName(), r))); |
| import java.util.List; | ||
|
|
||
| @RegistryDescription | ||
| public class RollingMachine extends VirtualizedRegistry<Pair<ResourceLocation, IRollingMachineCrafter.IRollingRecipe>> { |
There was a problem hiding this comment.
IRollingMachineCrafter.IRollingRecipe stores the ResourceLocation, so theres no need to have it be Pair<ResourceLocation, IRollingMachineCrafter.IRollingRecipe> instead of just IRollingMachineCrafter.IRollingRecipe
| if (time <= 0) { | ||
| GroovyLog.msg("Error adding Railcraft Blast Furnace recipe") | ||
| .error() | ||
| .add("time must be greater than 0, got: {}", time) | ||
| .post(); | ||
| return null; | ||
| } | ||
| if (slag < 0) { | ||
| GroovyLog.msg("Error adding Railcraft Blast Furnace recipe") | ||
| .error() | ||
| .add("slag must be non-negative, got: {}", slag) | ||
| .post(); | ||
| return null; | ||
| } |
There was a problem hiding this comment.
validate in the builder
| if (time <= 0) { | ||
| msg.add("time must be greater than 0, got: {}", time); | ||
| time = IBlastFurnaceCrafter.SMELT_TIME; | ||
| } | ||
| if (slag < 0) { | ||
| msg.add("slag must be non-negative, got: {}", slag); | ||
| slag = 1; | ||
| } |
There was a problem hiding this comment.
if there are any messages, the validation fails. just do
| if (time <= 0) { | |
| msg.add("time must be greater than 0, got: {}", time); | |
| time = IBlastFurnaceCrafter.SMELT_TIME; | |
| } | |
| if (slag < 0) { | |
| msg.add("slag must be non-negative, got: {}", slag); | |
| slag = 1; | |
| } | |
| msg.add(time <= 0, "time must be greater than 0, got: {}", time); | |
| msg.add(slag < 0, "slag must be non-negative, got: {}", slag); |
| @Property | ||
| private FluidStack fluid; |
There was a problem hiding this comment.
instead of this, use fluidOutput from parent
| @RegistryDescription | ||
| public class FluidFuels extends VirtualizedRegistry<FluidFuels.FuelEntry> { | ||
|
|
||
| private final Map<String, Integer> backupFuels = new HashMap<>(); |
There was a problem hiding this comment.
this is now completely unused
|
|
||
| public boolean remove(IRollingMachineCrafter.IRollingRecipe recipe) { | ||
| return Crafters.rollingMachine().getRecipes().removeIf(r -> { | ||
| if (r == recipe) { |
There was a problem hiding this comment.
if r == recipe well you can just do addBackup(recipe) + Crafters.rollingMachine().getRecipes().remove(recipe) then
| # Version of your mod. | ||
| # This field can be left empty if you want your mod's version to be determined by the latest git tag instead. | ||
| modVersion = 1.4.3 | ||
| modVersion = 1.4.4 |
There was a problem hiding this comment.
undo changing the version
|
I've fixed it. Please take a look and let me know if there are any issues |
WaitingIdly
left a comment
There was a problem hiding this comment.
one new thing. please actually resolve the other issues you have marked as resolved, but have not resolved.
|
check |
bro Railcraft compat